<%@ page isELIgnored="false" contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"></c:set>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>55社区</title>
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <%--引入公共样式--%>
    <jsp:include page="common.jsp"></jsp:include>

</head>
<body>
<header data-am-widget="header" class="am-header am-header-default sq-head ">
    <div class="am-header-left am-header-nav">
        <a href="javascript:history.back()" class="">
            <i class="am-icon-chevron-left"></i>
        </a>
    </div>
    <h1 class="am-header-title">
        <a href="" class="">管理收货地址</a>
    </h1>
    <div class="am-header-right am-header-nav">
        <a href="address/toaddressAdd.do" class="">
            <i class="am-icon-plus"></i>
        </a>
    </div>
</header>
<div style="height: 49px;"></div>
<ul class="address-list">


    <c:forEach var="bean" items="${addressList}" varStatus="ss">
        <li class="${bean.address_default==1?'curr':''}">
            <p>收货人：${bean.address_username}&nbsp;&nbsp;${fn:substring(bean.address_phone, 0, 3)}********</p>
            <p class="order-add1">
                收货地址：${bean.address_province}${bean.address_city}${bean.address_county}${bean.address_house}</p>
            <hr/>
            <div class="address-cz">
                <label class="am-radio am-warning">
                    <input class="setDefaule" address_id="${bean.address_id}" type="radio" name="radio3" value=""
                           data-am-ucheck   ${bean.address_default==1?'checked':''}> 设为默认
                </label>
                <a href=""><img src="${ctx}/static/images/bj.png" width="18"/>&nbsp;编辑</a>
                <a href="">删除</a>
            </div>
        </li>
    </c:forEach>



</ul>


<script>
    //点击按钮设置默认地址
    $(".setDefaule").click(function () {
        //添加样式
        //点击对象的父级（li）的兄弟级（li）的子集（a）移除类
        $(this).parent().parent().parent().siblings().removeClass("curr");
        //点击对象的父级（li）的兄弟级（li）移除类
        $(this).parent().parent().parent().addClass("curr");
        var address_id = $(this).attr("address_id");//获取地址ID
        var myData = {"address_id": address_id};
        $.post("${ctx}/address/setDefaultAddress.do", myData, function (data) {
            alert(data.msg);
        });
    });
</script>
</body>
</html>
